package vip.xiaonuo.common.util;

import java.util.Random;

/**
 * @author xsl
 * @date 2024-08-13 11:55
 **/
public class CommonStringUtil {
    public static String generateRandomString(int length){
        String characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        StringBuilder sb = new StringBuilder(length);
        Random random = new Random();

        for (int i = 0; i < length; i++) {
            int index = random.nextInt(characters.length());
            sb.append(characters.charAt(index));
        }

        return sb.toString();
    }
}
